package io.homework2;

import io.Student;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class Test2 {
    public static void main(String[] args) throws Exception {
        Student s = new Student("YiYi",18,"girl",new String[]{"yyyy"});
        FileOutputStream fos = new FileOutputStream("hw.txt");
        ObjectOutputStream oos = new ObjectOutputStream(fos);

        oos.writeObject(s);

        System.out.println("写出完成");
        oos.close();


        FileInputStream fis = new FileInputStream("hw.txt");
        ObjectInputStream ois = new ObjectInputStream(fis);

        Object o = ois.readObject();
        Student  s1 = (Student) o;
        System.out.println("读入完成");
        System.out.println(o);
        ois.close();

    }
}
